<template>
  <div>
    <div class="main">
      <eagle-input
        class="input_text"
        readonly
        label="文件名称"
        name="FileName"
        v-model="form.FileName"
        required
      ></eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="签发版文件类型"
        name="PlanTypeName"
        v-model="form.PlanTypeName"
        required
        v-if="form.IssueMainAttach"
      ></eagle-input>
       <eagle-input
        class="input_text"
        readonly
        label="编辑版文件类型"
        name="PlanTypeName"
        v-model="form.PlanTypeName"
        required
        v-if="!form.IssueMainAttach"
      ></eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="版本"
        v-model="form.IssueVersionNo"
        v-if="form.IssueVersionNo"
        name="IssueVersionNo"
        required
      ></eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="版本"
        v-model="form.EditVersionNo"
        v-if="form.EditVersionNo"
        name="EditVersionNo"
        required
      ></eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="文件编号"
        v-if="form.PlanNum"
        v-model="form.PlanNum"
        name="PlanNum"
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        v-if="isEdit && form.StatusName"
        label="效力状态"
        v-model="form.StatusName"
        name="StatusName"
        required
      >
      </eagle-input>
      <eagle-input
        label="下次评估日期"
        class="input_text"
        v-if="isEdit && form.NextEvaluateDate"
        :value="getDate(form.NextEvaluateDate)"
        readonly
      ></eagle-input>
      <eagle-input
        label="预警"
        class="input_text"
        v-if="isEdit && form.ExpireDays"
        :value="getDateDiffs(form.ExpireDays)"
        name="ExpireDays"
        readonly
      ></eagle-input>
      <eagle-input
        class="input_text"
        readonly
        v-if="form.ExplainOrgName"
        name="ExplainOrgName"
        label="解释部门"
        v-model="form.ExplainOrgName"
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        v-if="form.ApplyOrgName"
        autosize
        rows="1"
        name="ApplyOrgName"
        type="textarea"
        label="适用部门"
        v-model="form.ApplyOrgName"
      >
      </eagle-input>
      <eagle-input
        label="最近修改人"
        class="input_text"
        :value="form.EditChnName"
        readonly
      ></eagle-input>
      <eagle-input
        label="最近修改日期"
        class="input_text"
        :value="getDateTime(form.EditDate)"
        readonly
      ></eagle-input>
      <eagle-file-view
        :attachs="form.IssueMainAttach"
        v-show="form.IssueMainAttach"
        :isMust="true"
        :labelName="'签发版本'"
      />
      <eagle-file-view
        :attachs="form.EditMainAttach"
        v-show="form.EditMainAttach"
        :labelName="'编辑版本'"
      />
    </div>
  </div>
</template>

<script>
import { getDate, getDateTime, getDateDiffs } from "@/utils/getDate";

export default {
  data() {
    return {
      isEdit: this.$route.query.isEdit,
      filter: {
        code: this.$route.query.code,
      },
      form: {},
    };
  },
  created() {
    if (this.$route.query.code != null) {
      this.getDetail();
    }
  },
  methods: {
    getDate(value) {
      return getDate(value);
    },
    getDateTime(value) {
      return getDateTime(value);
    },
    getDateDiffs(value) {
      if (value != undefined && value != null) {
        if (value > 0) {
          return "逾期" + getDateDiffs(value);
        } else {
          return getDateDiffs(value);
        }
      }
    },
    getDetail() {
      let _this = this;
      _this.$axios
      .get("/PlanEmergencyFileManage/GetDetail",{params:_this.filter})
      .then((res) => {
        _this.form = res.data;
      });
    },
  },
};
</script>
